home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 48 / 048side1.d81 / binary mind read (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  3KB  |  101 lines

  1. 10 rem  binary mind reader
  2. 20 rem  and lie detector
  3. 30 rem  by royal c. jones
  4. 40 gosub60100
  5. 50 print"[147][154]think of a number--"
  6. 60 print"[159]a positive integer, please"
  7. 80 rem  first how big is it?
  8. 90 n$=" 1":rem  the binary number
  9. 100 for i=1 to 29:rem  lots of bits
  10. 110 n$=n$+"0"
  11. 120 print"[154]is your number less than"
  12. 130 print n$"[154] binary"
  13. 135 print"                                     [145]"
  14. 140 print 2^i"[154]decimal?"
  15. 150 gosub 620
  16. 160 if a$="y" goto 240
  17. 170 print"                                     [145][145]"
  18. 175 print"[154]then it is at least"i+1"[154]bits long"
  19. 180 d$=d$+"?":rem  place markers
  20. 190 next i
  21. 200 print"[147]       let's not get carried away!"
  22. 210 print"        [150]think of another number"
  23. 220 fora=1to2000:next:run50
  24. 240 rem  now for the number itself
  25. 250 n$=" 1":i=i-1:n=2^i
  26. 260 if n=1 goto 380:rem  no question
  27. 270 for j=i-1 to 0 step-1:print
  28. 280 print"your number looks like"
  29. 290 print n$;left$(d$,i+2-len(n$));
  30. 300 print" binary"
  31. 310 print"is your number less than"
  32. 315 print"                                   [145]"
  33. 320 print n+2^j"decimal?"
  34. 330 gosub 620
  35. 340 if a$="y" then n$=n$+"0":goto 360
  36. 350 n$=n$+"1":n=n+2^j
  37. 360 next j
  38. 380 rem  eureka!
  39. 390 print:print"[158][147]the number you are thinking of is"
  40. 400 print n$" [154]binary"
  41. 410 print n"[154]decimal"
  42. 420 print:print"am i correct?   [145]";
  43. 430 gosub 620:print
  44. 440 if a$="y"then print"as always":goto700
  45. 460 rem  the lie detector
  46. 470 print:print"[159]what is your number:";:le=15:nu=1:al=.:gosub60500:w=val(c$)
  47. 480 if w=n then print"[150]aha! just as i said!":goto700
  48. 490 if w<>int(w) thengosub1000:goto700
  49. 500 if w<1 thengosub1100:goto700
  50. 510 t=2^i:rem  the test number
  51. 520 if w<t goto 580
  52. 530 for j=i to 0 step-1
  53. 540 if n>=t+2^j then t=t+2^j:goto 570
  54. 550 if w<t+2^j goto 590
  55. 560 print"[150]aha! but you said it was less than":print t+2^j:goto700
  56. 570 if w>=t goto 590
  57. 580 print"[150]aha! but you said it was not less than":print t:goto700
  58. 590 next j
  59. 600 print"oh-oh! bad program":goto700
  60. 620 rem  input subroutine
  61. 630 print"[154]y[154]es or n[154]o:    [157][157][157]";:poke198,.
  62. 640 get a$:if a$<>"y"anda$<>"n"then640
  63. 650 print""a$"[146]":rem  hilight answer
  64. 655 ifpeek(203)<>64then655
  65. 660 return
  66. 700 ifpeek(203)<>64then700
  67. 705 print"[154]would you like to me to guess another?":poke198,.
  68. 710 a=peek(203):ifa<>25anda<>39then710
  69. 720 ifa=25thenrun50
  70. 730 goto60000
  71. 1000 print"but i asked for an integer":print"try again":return
  72. 1100 print"but i asked for a positive number":print"try again":return
  73. 60000 open15,8,15,"r0:hello connect=hello connect":input#15,er:close15
  74. 60010 ifer<>63thenend
  75. 60020 load"hello connect",8
  76. 60100 poke53280,11:poke53281, 0:print"[147][142]";
  77. 60101 print"[158]loadstarpresents:"
  78. 60102 print"[151][160]"
  79. 60103 print"[176]{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}[174]"
  80. 60104 print"[176]{$7b}[174][176]{$7b}[174]{$7d}[173][189]";
  81. 60105 print"[173][189]{$7d}{$7d}{$7d}{$7d}[156]binarymind";
  82. 60106 print"reader{$7d}{$7d}{$7d}{$7d}[156]";
  83. 60107 print"royalc.jones{$7d}{$7d}{$7d}{$7d}";
  84. 60108 print"[156]copyright1988{$7d}{$7d}";
  85. 60109 print"{$7d}{$7d}[176][174][176][174]{$7d}[173]{$7b}[189]";
  86. 60110 print"[173]{$7b}[189][173]{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}[189]"
  87. 60111 print"[158]pressspacetocontinue"
  88. 60120 ifpeek(203)<>60then60120
  89. 60130 return
  90. 60500 c$="":poke198,.:print"[164]";
  91. 60510 fora=1tole+1
  92. 60520 geta$:ifa$=""then60520
  93. 60530 ifa$=chr$(13)thenprint"[157] ":return
  94. 60540 ifa$=chr$(20)anda>1thenprint"[157][157]  [157][157][164]";:a=a-1:c$=left$(c$,a-1):goto60520
  95. 60550 if(a=le+1)then60520
  96. 60560 if(nu)and((a$>="0")and(a$<="9"))then60595
  97. 60570 if(al)and((a$>=" "anda$<="/")or(a$>=":"anda$<="z"))then60595
  98. 60580 if(al)thenif(a$>="[193]"anda$<="[218]")then60595
  99. 60590 goto60520
  100. 60595 print"[157]"a$;:poke212,.:print"[164]";:c$=c$+a$:next
  101.